﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class FRegister : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void Register(object s, EventArgs e)
    {
        Customer c = new Customer();
        CustomerBOL cBOL = new CustomerBOL();

        Acount a = new Acount();
        AcountBOL aBOL = new AcountBOL();
        try
        {
            a.Username = txtUsername.Text;
            a.Pass = txtPass.Text;
            a.Dateregistry = DateTime.Now;
            a.Acounttype = "Customer";
            c.Identification = txtIndentification.Text;
            c.Firstname = txtFirstname.Text;
            c.Lastname = txtLastname.Text;
            c.Age = Convert.ToInt32(txtAge.Text);
            c.Address = txtAddress.Text;
            c.Phonenumber = txtPhonenumber.Text;
            c.Email = txtEmail.Text;

            a.Identification = txtIndentification.Text;

            int result = cBOL.insertCustomer(c);
            int result1 = aBOL.insertAcount(a);

            if (result > 0 & result1 > 0)
            {
                thekydang.Text = "Register is successful!";
            }
            else
                thekydang.Text = "Register is error!";
        }
        catch (Exception ex)
        {
            thekydang.Text = ex.Message;
        }
        finally
        {
            c = null;
            a = null;
        }
    }
}